import http from '../../core/request'
import { Auth } from './index.type'

// 获取员工列表
const getStaff = (params: Auth.Params.Select) => {
  return http.get<Auth.Res.StaffList>('/customer-user/underling-list', params, { loading: true })
}

// 新增员工权限
const addEmployee = (params: Auth.Params.Create) => {
  return http.post('/customer-user/create-employee', params, { loading: true })
}

// 修改员工信息
const updateEmployee = (id: number, params: Partial<Auth.Params.Create>) => {
  return http.post(`/customer-user/${id}/update-employee`, params, { loading: true })
}

// 禁用员工账号
const disabledAccount = (params: string[]) => {
  return http.post('/user/disabled', { ids: params }, { loading: true })
}

// 启用员工账号
const enableAccount = (params: string[]) => {
  return http.post('/user/enable', { ids: params }, { loading: true })
}

// 获取员工角色列表
const getStaffAuth = () => {
  return http.get<Auth.Res.StaffAuth[]>('/customer/role/list', {}, { loading: false })
}
// 获取业务员列表
const getBusinessStaff = (data) => {
  return http.get<Auth.Res.CustomerList>('/users/role-users', data, { loading: true })
}

export default {
  getStaff,
  addEmployee,
  updateEmployee,
  getStaffAuth,
  disabledAccount,
  enableAccount,
  getBusinessStaff
}